class Solution(object):
    def isToeplitzMatrix(self, matrix):
        """
        :type matrix: List[List[int]]
        :rtype: bool
        """
        m = len(matrix)
        n = len(matrix[0])
        for j in range(n - 1):
            base = matrix[0][j]
            k = 1
            while k < m and j + k < n:
                if matrix[k][j + k] != base:
                    return False
                k += 1
        for i in range(m - 1):
            base = matrix[i][0]
            k = 1
            while k < n and i + k < m:
                if matrix[i + k][k] != base:
                    return False
                k += 1
        return True
